//
// Description: 5219. 每个小孩最多能分到多少糖果
// Created by Loading on 2022/4/3.
//

#include <bits/stdc++.h>

using namespace std;

int maximumCandies(vector<int> &candies, long long k) {
    long long l = 0, r = 1e12;
    // 二分查找最大糖果数目
    while (l < r) {
        /* 如果使用 mid = l + ((r - l) >> 1) 可能出现死循环 */
        auto mid = l + (r - l + 1 >> 1);
        auto cnt = 0ll;
        for (auto x : candies) {
            cnt += x / mid;
        }
        if (cnt >= k) {
            // mid值有效
            l = mid;
        } else {
            r = mid - 1;
        }
    }
    return l;
}

int main() {
    vector<int> candies{5, 8, 6};
    long long k = 3;
    auto res = maximumCandies(candies, k);
    cout << res << endl;

    return 0;
}